package com.tsing.spring_learn;


import com.tsing.spring_learn.config.UserConfig;
import com.tsing.spring_learn.config.explore.servicetest.DemoService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Map;


public class SpringLearnApplication {
    public static void main(String[] args) {

        // 指定扫描的包,将其放入Spring 容器中进行管理
        ApplicationContext context = new AnnotationConfigApplicationContext(
                "com.tsing.spring_learn.config");
        Object obj1 = context.getBean("beanObj1");
        Object obj2 = context.getBean("userConfig");
        System.out.println("obj1:" +  obj1);
        System.out.println("obj2:" + obj2);

        // 探究接口实现类全部执行某个方法
        Map<String, DemoService> serviceMap = context.getBeansOfType(DemoService.class);
        for (Map.Entry<String, DemoService> entry : serviceMap.entrySet()) {
            System.out.println("对象："+entry.getKey());
            entry.getValue().doSomething();
        }

    }


}
